capture log close
set linesize 120
macro drop _all
clear all
set more off
set scheme s1mono

*/ SET DIRECTORY */

*/ START LOG FILE */

log using WhyLeadersFightMonadicReplication.log, replace

*/ CHAPTER 2 */

*/ Figure 2.1 and Figure 2.2
use "WhyLeadersFightLEADDataset.dta"

sort ccode year
gen yr=year(startdate)
order yr
gen decade1870=0
replace decade1870=1 if inyear>=1870 & inyear<1880
gen decade1880=0
replace decade1880=1 if inyear>=1880 & inyear<1890
gen decade1890=0
replace decade1890=1 if inyear>=1890 & inyear<1900
gen decade1900=0
replace decade1900=1 if inyear>=1900 & inyear<1910
gen decade1910=0
replace decade1910=1 if inyear>=1910 & inyear<1920
gen decade1920=0
replace decade1920=1 if inyear>=1920 & inyear<1930
gen decade1930=0
replace decade1930=1 if inyear>=1930 & inyear<1940
gen decade1940=0
replace decade1940=1 if inyear>=1940 & inyear<1950
gen decade1950=0
replace decade1950=1 if inyear>=1950 & inyear<1960
gen decade1960=0
replace decade1960=1 if inyear>=1960 & inyear<1970
gen decade1970=0
replace decade1970=1 if inyear>=1970 & inyear<1980
gen decade1980=0
replace decade1980=1 if inyear>=1980 & inyear<1990
gen decade1990=0
replace decade1990=1 if inyear>=1990 & inyear<2000
gen decade2000=0
replace decade2000=1 if inyear>=2000 & inyear<2010
gen decade=.
replace decade=1 if decade1870==1
replace decade=2 if decade1880==1
replace decade=3 if decade1890==1
replace decade=4 if decade1900==1
replace decade=5 if decade1910==1
replace decade=6 if decade1920==1
replace decade=7 if decade1930==1
replace decade=8 if decade1940==1
replace decade=9 if decade1950==1
replace decade=10 if decade1960==1
replace decade=11 if decade1970==1
replace decade=12 if decade1980==1
replace decade=13 if decade1990==1
replace decade=14 if decade2000==1

label define decades 1 "1870s", add
label define decades 2 "1880s", add
label define decades 3 "1890s", add
label define decades 4 "1900s", add
label define decades 5 "1910s", add
label define decades 6 "1920s", add
label define decades 7 "1930s", add
label define decades 8 "1940s", add
label define decades 9 "1950s", add
label define decades 10 "1960s", add
label define decades 11 "1970s", add
label define decades 12 "1980s", add
label define decades 13 "1990s", add
label define decades 14 "2000s", add
label values decade decades
drop if decade==.

collapse (mean) milservice milnoncombat rebel combat (median) age, by(decade)
set scheme s1mono
twoway (line milservice decade, lwidth(medthick)), ylabel(0 "0%" .2 "20%" .4 "40%" .6 "60%") xtitle(Decade, size(medsmall) margin(medsmall)) ytitle(Percentage of Leaders, size(medsmall) margin(medsmall)) graphregion(fcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) lcolor(white) ilcolor(white)) xlabel(#14, labels labsize(small) labgap(small) valuelabel)
graph save Graph "ReplicationFigure2_1.gph", replace

twoway (line age decade, lwidth(medthick)), xtitle(Decade, size(medsmall) margin(medsmall)) ytitle(Median Age of Leaders, size(medsmall) margin(medsmall)) graphregion(fcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) lcolor(white) ilcolor(white)) xlabel(#14, labels labsize(small) labgap(small) valuelabel)
graph save Graph "ReplicationFigure2_2.gph", replace

clear

*/ Table 2.2 and Table 2.3 */

use WhyLeadersFightMonadicReplication.dta, clear

*/ Initial leader risk score */

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 yearssincemidinit y2 y3, robust cluster(leaderid)
predict leaderrisk if e(sample)
la var leaderrisk "Leader Attribute Risk Score"

*/ Initial system risk score */

logit cwinit cinc dem aut syscon irregular tau_lead fiveyearchallengelag lastwarwin lastwarloss lastwardraw yearssincemidinit y2 y3, robust cluster(ccode)
predict systemrisk if e(sample)
la var systemrisk "System Risk Score"

*/ generate MID initiation summary data for creation upon data collapse */
gen cwinit_sum = cwinit
la var cwinit_sum "Number of MID Initiations"

collapse (mean) leaderrisk systemrisk (sum) cwinit_sum (min) ccode inyear (max) outyear, by(leaderid leadername idacr)

*/ List top 35 conflict prone leaders, by leader risk score */
gsort -leaderrisk

list ccode idacr leaderid leadername leaderrisk systemrisk cwinit_sum in 1/35, table clean noobs

*/ List top 35 conflict prone leaders, by system risk score */

gsort -systemrisk

list ccode idacr leaderid leadername leaderrisk systemrisk cwinit_sum in 1/35, table clean noobs

*/ List top 2% of most dangerous leaders in reality, and their military dispute initiations, comparing how leader model v. system model predict their risk % */
gsort -leaderid
gsort -cwinit_sum

xtile pct = leaderrisk, nq(100)
xtile pct2 = systemrisk, nq(100)
xtile pct3 = cwinit_sum, nq(100)
replace pct=pct-1
replace pct2=pct2-1
replace pct3=pct3-1
list ccode idacr leaderid leadername pct pct2 pct3 cwinit_sum if pct3>=98, table clean noobs

clear

use WhyLeadersFightMonadicReplication.dta

*/ Figure 2.3 */

logit cwinit medicine illegit gender militarycareer aristocratlandowner marriedinpower royalty law journalism business orphanbinary rebelwin divorced careerpolitician bluecollar totalspouses teacher age childtotal rebel married leveledu warloss activist scienceeng police warwin religion parstability combat creative milnoncombat rebelloss officetenure1000 yearssincemidinit y2 y3, robust cluster(leaderid)

predict leaderrisk if e(sample)

estimates store m1

coefplot m1, keep(milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary) scheme(s1mono) rename(milnoncombat = "Military Service, No Combat" combat = "Military Service, Combat" rebel = "Rebel Service" warwin = "Prior War Win" warloss = "Prior War Loss" rebelwin = "Prior Rebel Win" rebelloss = "Prior Rebel Loss" leveledu = "Level of Education" age = "Age" teacher = "Occupation: Teacher" journalism = "Occupation: Journalism" law = "Occupation: Law" medicine = "Occupation: Medicine" religion = "Occupation: Religion" activist = "Occupation: Activist" careerpolitician = "Occupation: Career Politician" creative = "Occupation: Creative" business = "Occupation: Business Career" aristocratlandowner = "Occupation: Aristocrat" police = "Occupation: Police" militarycareer = "Occupation: Military Career" scienceeng = "Occupation: Science" bluecollar = "Occupation: Blue Collar" gender = "Gender" totalspouses = "Number of Spouses" married = "Married (Ever)" marriedinpower = "Married in Power" divorced = "Divorced" childtotal = "Number of Children" parstability = "Parental Stability" illegit = "Considered 'Illegitimate' Child" royalty = "Royalty" orphanbinary = "Orphan") grid(none) order(model1) scale(.75) aspectratio(1.4) xline(0)

graph save Graph "ReplicationFigure2_3.gph", replace

clear

*/ CHAPTER 3 */

use WhyLeadersFightMonadicReplication.dta

*/ NOTE: The maps in Why Leaders Fight were created by using the same leader risk model presented in Figure 2.3, then plotting the risk scores for those leaders on maps in different time periods */
*/ NOTE: maps created using cshapes and the spmap command */

*/ Figure 3.3 */
logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 yearssincemidinit y2 y3, robust cluster(leaderid)
predict leaderrisk if e(sample)

gen region="North America" if ccode>=0
replace region="Central America" if ccode>20
replace region="Americas" if ccode>100
replace region="Europe" if ccode>200
replace region="Africa" if ccode>400
replace region="Middle East" if ccode>600
replace region="Asia" if ccode>700

collapse (mean) leaderrisk, by(year)
sort leaderrisk
sort year

twoway line leaderrisk year || qfit leaderrisk year, lp(dash) legend(label(1 "Mean Risk Score") label(2 "Quadratic Fit")) xlabel(#10) ytitle(Leader Risk Score) 

graph save Graph "ReplicationFigure3_3.gph", replace

*/ Figure 3.4 */

clear

use WhyLeadersFightMonadicReplication.dta

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 yearssincemidinit y2 y3, robust cluster(leaderid)
predict leaderrisk if e(sample)

xtile leaderrisk_d = leaderrisk, nq(10)

gen region=1 if ccode>=0
replace region=2 if ccode>20
replace region=3 if ccode>=200
replace region=4 if ccode>=400
replace region=5 if ccode>=600
replace region=6 if ccode>=700

label define region 1 "North America" 2 "Central/South America" 3 "Europe" 4 "Sub-Saharan Africa" 5 "Middle East/N. Africa" 6 "Asia"

sort region
by region: tab leaderrisk_d

* We then used these totals to create the bubble chart seen in Figure 3.4 in Excel *

*/ Figure 3.6 */

clear

use WhyLeadersFightMonadicReplication.dta

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 yearssincemidinit y2 y3, robust cluster(leaderid)
predict leaderrisk if e(sample)

logit cwinit cinc dem aut syscon irregular tau_lead fiveyearchallengelag lastwarwin lastwarloss lastwardraw yearssincemidinit y2 y3, robust cluster(ccode)
predict systemrisk if e(sample)

collapse leaderrisk systemrisk, by(year ccode)

describe
summarize

sort ccode year
tsset ccode year

*/ Standardize variables */

egen z2systemrisk = std(systemrisk)
egen z2leaderrisk = std(leaderrisk)

quietly twoway line systemrisk year if ccode==2 || qfit systemrisk year if ccode==2, legend(label(1 "System Risk Score") label(2 "Quadratic Fit") r(2) m(tiny) bm(tiny) si(small)) xlabel(#10) saving(system, replace)
quietly twoway line leaderrisk year if ccode==2 || qfit leaderrisk year if ccode==2, legend(label(1 "Leader Risk Score") label(2 "Quadratic Fit") r(2) m(tiny) bm(tiny) si(small)) xlabel(#10) saving(leader, replace)
quietly twoway line z2systemrisk z2leaderrisk year if ccode==2, lp(dash) legend(label(1 "System Risk Score") label(2 "Leader Risk Score") r(2) m(tiny) bm(tiny) si(small)) xlabel(#10) saving(zstandardsystemleader, replace)

*/ With quadratic fit lines */

twoway line z2systemrisk z2leaderrisk year if ccode==2 || qfit z2systemrisk year if ccode==2, lp(dash) || qfit z2leaderrisk year if ccode==2, lp(dot) ||, legend(label(1 "System Risk Score") label(2 "Leader Risk Score") label(3 "System Risk (Fitted)") label(4 "Leader Risk (Fitted)") r(2) m(tiny) bm(tiny) si(small)) xlabel(#10) ytitle("Risk Score (Standardized)")

graph save Graph "ReplicationFigure3_6.gph", replace

clear

*/ Figures 3.8, 3.10, 3.12, and 3.13 */

use WhyLeadersFightMonadicReplication.dta

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 yearssincemidinit y2 y3, robust cluster(leaderid)
predict leaderrisk if e(sample)

*/ Generate yearly average for each country */

collapse (mean) leaderrisk, by(year ccode)

*/ Generate yearly average by region */

gen region=1 if ccode>=0
replace region=2 if ccode>20
replace region=3 if ccode>100
replace region=4 if ccode>200
replace region=5 if ccode>400
replace region=6 if ccode>600
replace region=7 if ccode>700

collapse (mean) leaderrisk, by(year region)

mean leaderrisk, over(region)

sort leaderrisk
sort year

twoway line leaderrisk year if year>=1900 & region==6 || qfit leaderrisk year if year>=1900 & region==6, lp(dash) legend(label(1 "Mean Risk Score") label(2 "Quadratic Fit")) xlabel(#10) xlabel(#10)
graph save Graph "ReplicationFigure3_8.gph", replace

twoway line leaderrisk year if year>=1950 & region==5 || qfit leaderrisk year if year>=1950 & region==5, lp(dash) legend(label(1 "Mean Risk Score") label(2 "Quadratic Fit")) xlabel(#10) xlabel(#10)
graph save Graph "ReplicationFigure3_10.gph", replace

twoway line leaderrisk year if region==3 || qfit leaderrisk year if region==3, lp(dash) legend(label(1 "Mean Risk Score") label(2 "Quadratic Fit")) xlabel(#10) xlabel(#10)
graph save Graph "ReplicationFigure3_12.gph", replace

twoway line leaderrisk year if region==2 || qfit leaderrisk year if region==2, lp(dash) legend(label(1 "Mean Risk Score") label(2 "Quadratic Fit")) xlabel(#10) xlabel(#10)
graph save Graph "ReplicationFigure3_13.gph", replace

estimates clear
clear

*/ CHAPTER 4 */

*/ Data for Figures 4.1 and 4.2 */

use WhyLeadersFightMonadicReplication.dta

*/ Generate Figure 4.1 data */
estsimp logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss age aut cinc tau_lead officetenure1000 fiveyearchallengelag yearssincemidinit y2 y3, robust cluster(leaderid)
setx mean
simqi, pr
setx combat 0 milnoncombat 0 warwin 0 warloss 0
simqi, pr
setx combat 1 warwin mean warloss mean
simqi, pr
setx milnoncombat 1 combat 0 warwin 0 warloss 0
simqi, pr
setx  mean
setx rebel 0 rebelloss 0 rebelwin 0
simqi, pr
setx rebel 1 rebelloss mean rebelwin mean
simqi, pr
setx milnoncombat 1 warwin 0 warloss 0
simqi, pr

*/ Graph created using Excel */

drop b1-b17

*/ Generate Figure 4.2 data */

gen milaut=milnoncombat*aut
label var milaut "Military Service, No Combat * Autocracy"
gen combataut=combat*aut
label var combataut "Military Service, Combat * Autocracy"
gen rebelaut=rebel*aut
label var rebelaut "Prior Rebel Participation * Autocracy"
gen milrebel=milnoncombat*rebel
label var milrebel "Military Service, No Combat * Rebel"
gen combatrebel=combat*rebel
label var combatrebel "Military Service, Combat * Rebel"

estsimp logit cwinit milnoncombat combat rebel milaut combataut rebelaut milrebel combatrebel warwin warloss rebelwin rebelloss age aut cinc tau_lead officetenure1000 fiveyearchallengelag yearssincemidinit y2 y3, robust cluster(leaderid)
setx mean
setx milnoncombat 0 combat 0 rebel 0 milrebel 0 combatrebel 0 warwin 0 warloss 0 rebelwin 0 rebelloss 0 aut 0 milaut 0 combataut 0 rebelaut 0 age mean cinc mean tau_lead mean officetenure1000 mean yearssincemidinit mean y2 mean y3 mean
simqi, pr
setx milnoncombat 0 combat 1 rebel 0 milrebel 0 combatrebel 0 warwin 0 warloss 0 rebelwin 0 rebelloss 0 aut 0 milaut 0 combataut 0 rebelaut 0 age mean cinc mean tau_lead mean officetenure1000 mean yearssincemidinit mean y2 mean y3 mean
simqi, pr
setx milnoncombat 0 combat 1 rebel 0 milrebel 0 combatrebel 0 warwin 0 warloss 0 rebelwin 0 rebelloss 0 aut 1 milaut 0 combataut 1 rebelaut 0 age mean cinc mean tau_lead mean officetenure1000 mean yearssincemidinit mean y2 mean y3 mean
simqi, pr
setx milnoncombat 0 combat 0 rebel 0 milrebel 0 combatrebel 0 warwin 0 warloss 0 rebelwin 0 rebelloss 0 aut 1 milaut 0 combataut 0 rebelaut 0 age mean cinc mean tau_lead mean officetenure1000 mean yearssincemidinit mean y2 mean y3 mean
simqi, pr

*/ Graph created using Excel */

drop b1-b22

*/ Start generating regression models for table A.8 in technical appendix */
logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss age aut cinc tau_lead officetenure1000 fiveyearchallengelag yearssincemidinit y2 y3, robust cluster(leaderid)
estimates store m1

logit cwinit milnoncombat combat rebel milaut combataut rebelaut milrebel combatrebel warwin warloss rebelwin rebelloss age aut cinc tau_lead officetenure1000 fiveyearchallengelag yearssincemidinit y2 y3, robust cluster(leaderid)
estimates store m2

*/ Figure 4.3 */

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer interpreter scienceeng gender married marriedinpower divorced totalspouses childtotal parstability illegit royalty orphanbinary officetenure1000 yearssincemidinit y2 y3, robust cluster(leaderid)
estimates store m3

margins, at(age=(20(5)100)) atmeans vsquish post
marginsplot, recast(line) recastci(rarea) graphregion(fcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) lcolor(white) ilcolor(white)) ylabel(, nogrid) xtitle(, height(8)) ytitle("Probability of Military Conflict Initiation", height(8)) title(" ",)
graph save Graph "ReplicationFigure4_3.gph", replace

*/ Figure 4.4 */

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer interpreter scienceeng gender married marriedinpower divorced totalspouses childtotal parstability illegit royalty orphanbinary officetenure1000 c.age##aut yearssincemidinit y2 y3, robust cluster(leaderid)
estimates store m4

margins aut, at(age=(20(5)100))  atmeans vsquish
marginsplot, recast(line) noci graphregion(fcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) lcolor(white) ilcolor(white)) ylabel(, nogrid) xtitle(, height(8)) ytitle("Probability of Military Conflict Initiation", height(8)) title(" ",) plot( , label("Non-Autocracy" "Autocracy"))
graph save Graph "ReplicationFigure4_4.gph", replace

esttab m1 m2 m3 m4 using AppendixTableA_8.rtf, replace onecell se pr2 t(3) b(a3) scalars(ll) legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) mtitles("Model For Figure 4.1" "Model For Figure 4.2" "Model For Figure 4.3" "Model For Figure 4.4")

clear

*/ CHAPTER 5 */

*/ Figure 5.1 */

use "Figure5_1.dta", clear

*/ This dataset collapses the leader risk data by leader, as per the replication for Figure 2.3, but then also merges in data on Childhood War Experience */

collapse (sum) war_no_tot (max) war_exp if adolescent == 0, by(year)

*/ This collapses again by year to set up Figure 5.1 */

twoway line war_no_tot year if year > 1875 ||  qfit war_no_tot year if year > 1875, lp(dash) xlabel(#10) legend(order(1 "Yearly Count of Childhood War Exposures" 2 "Quadratic Fit") rows(2) region(lcolor(white))) xtitle("Year", margin(medsmall)) ytitle("Count of Childhood War Exposure", margin(small)) ylabel(, nogrid) scheme(s1mono) graphregion(fcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) lcolor(white) ilcolor(white))
graph save Graph "ReplicationFigure5_1.gph", replace

clear

*/ Table 5.1 */

use WhyLeadersFightMonadicReplication.dta

*/ First, regenerate data from Figure 2.3 */

*/ Initial leader risk score */

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 yearssincemidinit y2 y3, robust cluster(leaderid)
predict leaderrisk if e(sample)
la var leaderrisk "Leader Attribute Risk Score"

*/ Initial system risk score */

logit cwinit cinc dem aut syscon irregular tau_lead fiveyearchallengelag lastwarwin lastwarloss lastwardraw yearssincemidinit y2 y3, robust cluster(ccode)
predict systemrisk if e(sample)
la var systemrisk "System Risk Score"

*/ generate MID initiation summary data for creation upon data collapse */
gen cwinit_sum = cwinit
la var cwinit_sum "Number of MID Initiations"

collapse (mean) leaderrisk systemrisk (sum) cwinit_sum (min) ccode inyear gender (max) outyear, by(leaderid leadername idacr)

*/ Finally, create Table 5.1 */

gsort -cwinit_sum

list ccode idacr leaderid leadername leaderrisk cwinit_sum if gender==0 & cwinit_sum>0, table clean noobs

*/ Note that duplicate leaders, e.g. leaders with multiple leader IDs because they served two different times, are averaged */

*/ Table created from the data above using Excel */

*/ Figure 5.4 */

gsort -leaderrisk

list ccode idacr leaderid leadername leaderrisk cwinit_sum if gender==1 in 1/10, table clean noobs

*/ Graph created from the data above using Excel */

*/ Figure 5.3 */

gen female=0
replace female=1 if gender==0
label define female 0 "Male", add
label define female 1 "Female", add
label values female female

graph box leaderrisk, over(female) box(1, fcolor(none) lcolor(black)) box(2, fcolor(none) lcolor(black)) medtype(marker) medmarker(mcolor(black) msize(medium)) ytitle(Leader Risk Score) ytitle(, margin(medium)) yscale(noline) ylabel(, nogrid) scheme(s1mono) graphregion(fcolor(white) ifcolor(white)) plotregion(fcolor(white) ifcolor(white) ilcolor(white))
graph save Graph "ReplicationFigure5_3.gph", replace

clear

*/ Figure 5.2 */

use "WhyLeadersFightLEADDataset.dta"

sort ccode year
gen yr=year(startdate)
order yr
gen decade1870=0
replace decade1870=1 if inyear>=1870 & inyear<1880
gen decade1880=0
replace decade1880=1 if inyear>=1880 & inyear<1890
gen decade1890=0
replace decade1890=1 if inyear>=1890 & inyear<1900
gen decade1900=0
replace decade1900=1 if inyear>=1900 & inyear<1910
gen decade1910=0
replace decade1910=1 if inyear>=1910 & inyear<1920
gen decade1920=0
replace decade1920=1 if inyear>=1920 & inyear<1930
gen decade1930=0
replace decade1930=1 if inyear>=1930 & inyear<1940
gen decade1940=0
replace decade1940=1 if inyear>=1940 & inyear<1950
gen decade1950=0
replace decade1950=1 if inyear>=1950 & inyear<1960
gen decade1960=0
replace decade1960=1 if inyear>=1960 & inyear<1970
gen decade1970=0
replace decade1970=1 if inyear>=1970 & inyear<1980
gen decade1980=0
replace decade1980=1 if inyear>=1980 & inyear<1990
gen decade1990=0
replace decade1990=1 if inyear>=1990 & inyear<2000
gen decade2000=0
replace decade2000=1 if inyear>=2000 & inyear<2010
gen decade=.
replace decade=1 if decade1870==1
replace decade=2 if decade1880==1
replace decade=3 if decade1890==1
replace decade=4 if decade1900==1
replace decade=5 if decade1910==1
replace decade=6 if decade1920==1
replace decade=7 if decade1930==1
replace decade=8 if decade1940==1
replace decade=9 if decade1950==1
replace decade=10 if decade1960==1
replace decade=11 if decade1970==1
replace decade=12 if decade1980==1
replace decade=13 if decade1990==1
replace decade=14 if decade2000==1

label define decades 2 "1880s", add
label define decades 1 "1870s", add
label define decades 3 "1890s", add
label define decades 4 "1900s", add
label define decades 5 "1910s", add
label define decades 6 "1920s", add
label define decades 7 "1930s", add
label define decades 8 "1940s", add
label define decades 9 "1950s", add
label define decades 10 "1960s", add
label define decades 11 "1970s", add
label define decades 12 "1980s", add
label define decades 13 "1990s", add
label define decades 14 "2000s", add
label values decade decades
drop if decade==.

*/ Generate number of women leaders per decade */
*/ NOTE: This just runs through 2004 */

gen uniquewoman=.
replace uniquewoman=3 if decade==10
replace uniquewoman=4 if decade==11
replace uniquewoman=8 if decade==12
replace uniquewoman=19 if decade==13
replace uniquewoman=7 if decade==14

label var uniquewoman "Number of Women Leaders"
label define uniquewoman 1 "Number of Women Leaders", add
label values uniquewoman uniquewoman

*/ Generate number of women leader-years per decade */

gen woman=0
replace woman=1 if gender==0
label var woman "Number of Women Leader-Years"
label define woman 1 "Women Leader-Years", add
label values woman woman

graph bar (rawsum) woman (mean) uniquewoman if decade>=9, over(decade, label(labgap(small) alt)) ytitle(Number Per Decade) ytitle(, margin(medium)) ylabel(, nogrid) scheme(s1mono) graphregion(fcolor(white) ifcolor(white) ilcolor(white)) plotregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) legend( label(1 "Women Leader-Years") label(2 "Women Leaders (Count)") region(lcolor(white)))
graph save Graph "ReplicationFigure5_2.gph", replace

clear

*/ CHAPTER 6 */

use "Figure6_1-6_2.dta", clear

*/ This dataset merges the leader risk score data into war data based on Horowitz, Simpson, & Stam 2011. It is presented as a separate dataset for simplicity */

*/ Figure 6.1 */

graph bar (mean) wdl if endwarleader==1, over(risk_q, label(labgap(small) alt)) ytitle(Average War Outcome (0 = Loss, 1 = Draw, 2 = Win)) ytitle(, margin(medium)) ylabel(, nogrid) scheme(s1mono) graphregion(fcolor(white) ifcolor(white) ilcolor(white)) plotregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))

graph save Graph "ReplicationFigure6_1.gph", replace

*/ Figure 6.2 */

graph bar (mean) finalcas, over(risk_q, label(labgap(small) alt)) ytitle(Average War Deaths) ytitle(, margin(medium)) ylabel(, nogrid) scheme(s1mono) graphregion(fcolor(white) ifcolor(white) ilcolor(white)) plotregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))

graph save Graph "ReplicationFigure6_2.gph", replace

estimates clear
clear

*/ TECHNICAL APPENDIX */

use WhyLeadersFightMonadicReplication.dta

*/ Appendix Table A.1, Replication and Extension of figure 2.3 in Why Leaders Fight */

*/ A.1 - Model 1 */
logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 yearssincemidinit y2 y3, robust cluster(leaderid)
estimates store m1

*/ A.1 - Model 2 */
*/ Drop leader years with multiple leaders per country but only one started MID (footnote 11, p. 65) */

duplicates tag ccode year, gen(duplicates)
drop if duplicates>=1 & cwinit==0

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 yearssincemidinit y2 y3, robust cluster(leaderid)
estimates store m2

clear

*/ A.1 - Model 3 */
*/ Only allow 1 MID initiation per leader year */

use WhyLeadersFightMonadicReplication.dta

duplicates drop leaderid year if cwinit==1, force

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 yearssincemidinit y2 y3, robust cluster(leaderid)
estimates store m3

*/ Create Appendix Table A.1 */

esttab m1 m2 m3 using AppendixTableA_1.rtf, replace onecell se pr2 t(3) b(a3) scalars(ll) legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) mtitles("Leader Risk Model" "Drop Duplicate Non-MID Leaders" "One MID Per Leader Year")

*/ Appendix Table A.2, Leader Peace Years */

clear
use WhyLeadersFightMonadicReplication.dta

*/ Leader risk score with leader-based peace years */

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 leaderpeaceyears leaderpeaceyears2 leaderpeaceyears3, robust cluster(leaderid)
predict leaderrisk2 if e(sample)
la var leaderrisk2 "Leader Attribute Risk Score (Leader Peace Years)"

*/ generate MID initiation summary data for creation upon data collapse */
gen cwinit_sum = cwinit
la var cwinit_sum "Number of MID Initiations"

collapse (mean) leaderrisk2 (sum) cwinit_sum (min) ccode inyear (max) outyear, by(leaderid leadername idacr)

*/ List top 10 conflict prone leaders, by leader risk score */
gsort -leaderrisk2

list ccode idacr leaderid leadername leaderrisk2 cwinit_sum in 1/10, table clean noobs

*/ Table A.2 generated by comparing the output above to Table 2.2 */

clear
estimates clear

*/ Table A.3: Combined Model */

use WhyLeadersFightMonadicReplication.dta

*/ Initial leader risk score */

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 yearssincemidinit y2 y3, robust cluster(leaderid)
estimates store m1

*/ Initial system risk score */

logit cwinit cinc dem aut syscon irregular tau_lead fiveyearchallengelag lastwarwin lastwarloss lastwardraw yearssincemidinit y2 y3, robust cluster(ccode)
estimates store m2

*/ Combined model */
logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 cinc dem aut syscon irregular tau_lead fiveyearchallengelag lastwarwin lastwarloss lastwardraw yearssincemidinit y2 y3, robust cluster(leaderid)
estimates store m3

*/ Output table for online appendix */

esttab m1 m2 m3 using AppendixTableA_3.rtf, replace onecell se pr2 t(3) b(a3) scalars(ll) legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) mtitles("Leader Risk Model" "System Risk Model" "Combined Model")

estimates clear

*/ Table A.4 - Alternative DVs */

*/Initial leader risk score with use of force DV + use of force leader-specific splines */
logit force2dv milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 noncountryforceyrs noncountryforceyrs2 noncountryforceyrs3, robust cluster(leaderid)
predict leaderrisk if e(sample)
la var leaderrisk "Leader Attribute Risk Score"

*/ Initial system risk score with use of force DV */
logit force2dv cinc dem aut syscon irregular tau_lead fiveyearchallengelag lastwarwin lastwarloss lastwardraw noncountryforceyrs noncountryforceyrs2 noncountryforceyrs3, robust cluster(ccode)
predict systemrisk if e(sample)
la var systemrisk "System Risk Score"

*/ generate force summary data for creation upon data collapse */
gen force_sum = force2dv
la var force_sum "Number of Conflicts Where Both Sides Used Force"

collapse (mean) leaderrisk systemrisk (sum) force_sum (min) ccode inyear (max) outyear, by(leaderid leadername idacr)

*/ List top 2% of most dangerous leaders in reality based on DV and compare how leader model v. system model predict their risk % */
gsort -leaderid
gsort -force_sum

xtile pct = leaderrisk, nq(100)
xtile pct2 = systemrisk, nq(100)
xtile pct3 = force_sum, nq(100)
replace pct=pct-1
replace pct2=pct2-1
replace pct3=pct3-1
list ccode idacr leaderid leadername pct pct2 pct3 force_sum if pct3>=98, table clean noobs

*/ Use this output to generate Appendix Table A.4 */

clear
estimates clear

*/ Table A.5 - Randomly Selected Leaders */

use WhyLeadersFightMonadicReplication.dta

*/ Randomly Selected Leaders */

keep if treatment==1

*/ Initial leader risk score */
*/ excludes medicine, police, scienceeng, illegit from base model since all predict failure perfectly in this pool of leaders */
logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law religion activist careerpolitician creative business aristocratlandowner militarycareer bluecollar gender totalspouses married marriedinpower divorced childtotal parstability royalty orphanbinary officetenure1000 yearssincemidinit y2 y3, robust cluster(leaderid)
lstat
predict leaderrisk if e(sample)
la var leaderrisk "Leader Attribute Risk Score"

*/ Initial system risk score */

logit cwinit cinc dem aut syscon irregular tau_lead fiveyearchallengelag lastwarwin lastwarloss lastwardraw yearssincemidinit y2 y3, robust cluster(ccode)
lstat
predict systemrisk if e(sample)
la var systemrisk "System Risk Score"

*/ generate MID initiation summary data for creation upon data collapse */
gen cwinit_sum = cwinit
la var cwinit_sum "Number of MID Initiations"

collapse (mean) leaderrisk systemrisk (sum) cwinit_sum (min) ccode inyear (max) outyear, by(leaderid leadername idacr)

*/ List all leaders in this pool 
gsort -leaderid
gsort -cwinit_sum

xtile pct = leaderrisk, nq(100)
xtile pct2 = systemrisk, nq(100)
xtile pct3 = cwinit_sum, nq(100)
replace pct=pct-1
replace pct2=pct2-1
replace pct3=pct3-1
list ccode idacr leaderid leadername pct pct2 pct3 cwinit_sum if cwinit_sum>=2, table clean noobs

*/ Use this output to generate Appendix Table A.5 */

clear

*/ Tables A.6 and A.7 - Coarsened Exact Matching */

*/ Demonstrating consistency of the results when using matching: footnote 66, p. 127 */

use WhyLeadersFightMonadicReplication.dta, clear
drop if milservice==.

*/ Matching on system variables */

*/ Use military service as treatment because if it is country-level attributes driving a selection process, it would be attributes that mean it is the general conflict propensity of countries */
*/ Not variables like national military service, driving the outcomes */

imb cinc dem aut tau_lead irregular fiveyearchallengelag, treatment(milservice)
cem cinc dem aut tau_lead irregular fiveyearchallengelag, treatment(milservice)

quietly logit cwinit milservice rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 yearssincemidinit y2 y3 [iweight=cem_weights], robust cluster(leaderid)
estimates store m1
predict leaderrisk if e(sample)
la var leaderrisk "Leader Attribute Risk Score"

esttab m1 using AppendixTableA_6.rtf, replace onecell se pr2 t(3) b(a3) scalars(ll) legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) mtitles("Leader Risk Model: Coarsened Exact Matching")

*/ Initial system risk score */

logit cwinit cinc dem aut syscon irregular tau_lead fiveyearchallengelag lastwarwin lastwarloss lastwardraw yearssincemidinit y2 y3, robust cluster(ccode)
predict systemrisk if e(sample)
la var systemrisk "System Risk Score"

*/ generate MID initiation summary data for creation upon data collapse */
gen cwinit_sum = cwinit
la var cwinit_sum "Number of MID Initiations"

collapse (mean) leaderrisk systemrisk (sum) cwinit_sum (min) ccode inyear (max) outyear, by(leaderid leadername idacr)

gsort -leaderid
gsort -cwinit_sum

xtile pct = leaderrisk, nq(100)
xtile pct3 = cwinit_sum, nq(100)
replace pct=pct-1
replace pct3=pct3-1
list ccode idacr leaderid leadername pct cwinit_sum if pct3>=98, table clean noobs

*/ Use this output to generate Table A.7 */

estimates clear
clear

*/ Table A.9: Childhood War */
use "Figure5_1.dta", clear

logit binarymid milservice war_exp, robust cluster(leaderid)
estimates store m1

esttab m1 using AppendixTableA_9.rtf, replace onecell se pr2 t(3) b(a3) scalars(ll) legend label collabels(none) varlabels(_cons Constant) star(* 0.10 ** 0.05 *** 0.01) mtitles("Childhood War Model")

*/ RESULTS ARE CONSISTENT WITH UPDATED MONADIC FILE */

use WhyLeadersFightMonadicReplication_updated.dta, clear

*/ Initial leader risk score */

logit cwinit milnoncombat combat rebel warwin warloss rebelwin rebelloss leveledu age teacher journalism law medicine religion activist careerpolitician creative business aristocratlandowner police militarycareer scienceeng bluecollar gender totalspouses married marriedinpower divorced childtotal parstability illegit royalty orphanbinary officetenure1000 yearssincemidinit y2 y3, robust cluster(leaderid)
predict leaderrisk if e(sample)
la var leaderrisk "Leader Attribute Risk Score"

*/ Initial system risk score */

logit cwinit cinc dem aut syscon irregular tau_lead fiveyearchallengelag lastwarwin lastwarloss lastwardraw yearssincemidinit y2 y3, robust cluster(ccode)
predict systemrisk if e(sample)
la var systemrisk "System Risk Score"

*/ generate MID initiation summary data for creation upon data collapse */
gen cwinit_sum = cwinit
la var cwinit_sum "Number of MID Initiations"

collapse (mean) leaderrisk systemrisk (sum) cwinit_sum (min) ccode inyear (max) outyear, by(leaderid leadername idacr)

*/ List top 35 conflict prone leaders, by leader risk score */
gsort -leaderrisk

list ccode idacr leaderid leadername leaderrisk systemrisk cwinit_sum in 1/35, table clean noobs

*/ Note that the order of the very top changes slightly, but not in a fundamental way */

*/ List top 2% of most dangerous leaders in reality, and their military dispute initiations, comparing how leader model v. system model predict their risk % */
gsort -leaderid
gsort -cwinit_sum

xtile pct = leaderrisk, nq(100)
xtile pct2 = systemrisk, nq(100)
xtile pct3 = cwinit_sum, nq(100)
replace pct=pct-1
replace pct2=pct2-1
replace pct3=pct3-1
list ccode idacr leaderid leadername pct pct2 pct3 cwinit_sum if pct3>=99, table clean noobs

*/ CLOSE LOG FILE */

log close

*/ CLEAR DATA */

clear
